DROP TABLE PASSAGEIRO CASCADE CONSTRAINTS;

CREATE TABLE PASSAGEIRO
(
	CODIGO     VARCHAR2(3) NOT NULL ENABLE,
	NOME       VARCHAR2(20) NOT NULL ENABLE,
	SOBRENOME  VARCHAR2(50) NOT NULL ENABLE,
	SEXO       VARCHAR2(20) NOT NULL ENABLE,
	RG         VARCHAR2(15) NULL,
	CPF        VARCHAR2(15) NOT NULL ENABLE,
	ENDERECO   VARCHAR2(70) NOT NULL ENABLE,
	BAIRRO     VARCHAR2(20) NULL,
	DT_NASC    VARCHAR2(10) NOT NULL ENABLE,
	CIDADE     VARCHAR2(50) NOT NULL ENABLE,
	ESTADO     VARCHAR2(2) NOT NULL ENABLE,
	CEP        VARCHAR2(8) NULL,
	TEL        VARCHAR2(11) NOT NULL ENABLE,
	EMAIL      VARCHAR2(70) NOT NULL ENABLE,
	SENHA      VARCHAR2(10) NOT NULL ENABLE
);


ALTER TABLE PASSAGEIRO ADD CONSTRAINT PK_PASSAGEIRO
	PRIMARY KEY (CODIGO) 
 USING INDEX 
;

CREATE OR REPLACE TRIGGER  "BI_PASSAGEIRO" 
  before insert on "PASSAGEIRO"              
  for each row 
begin  
  if :NEW."CODIGO" is null then
    select "PASSAGEIRO_SEQ".nextval into :NEW."CODIGO" from dual;
  end if;
end;
/
ALTER TRIGGER  "BI_PASSAGEIRO" ENABLE;

CREATE SEQUENCE "PASSAGEIRO_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE ;